﻿using System;
using System.Windows.Data;

namespace Hopscotch.Presentation.Common.Converters
{
    [ValueConversion(typeof(DataErrorInfo), typeof(Uri))]
    public class DataErrorInfoToImageConverter : IValueConverter
    {
        public Uri ErrorIcon { get; set; }
        public Uri WarningIcon { get; set; }
        public Uri InfoIcon { get; set; }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DataErrorInfo dei = value as DataErrorInfo;
            if (dei != null)
            {
                switch (dei.ErrorType)
                {
                    case ErrorType.Error:
                        return ErrorIcon;
                    case ErrorType.Warning:
                        return WarningIcon;
                    case ErrorType.Info:
                        return InfoIcon;
                }
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
